package com.zmj.sy.mom.srv.aps.bean.vo.base;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@NoArgsConstructor
@Getter
@Setter
public class BaseSelectItemResVo {

    @ApiModelProperty("文本")
    private String text;

    @ApiModelProperty("值")
    private Object value;

    @ApiModelProperty("扩展字段")
    private Map<String, Object> attr = new HashMap<>();

    public BaseSelectItemResVo(String text, Object value) {
        this.text = text;
        this.value = value;
    }

    public BaseSelectItemResVo(String text, Object value, Object... attr) {
        this.text = text;
        this.value = value;

        if (attr != null && attr.length > 0) {
            for (int i = 0; i < attr.length; i += 2) {
                this.attr.put((String) attr[i], attr[i + 1]);
            }
        }
    }


}
